use chrono::Utc;
use rand::distributions::{Alphanumeric, DistString};
use uuid::Uuid;

pub fn uuid_v4() -> Uuid {
    Uuid::new_v4()
}

pub fn uuid_v4_str() -> String {
    let mut buf = [b'!'; 36];
    uuid_v4().simple().encode_lower(&mut buf).to_owned()
}

pub fn ulid_str() -> String {
    rusty_ulid::Ulid::generate().to_string()
}

pub fn current_date() -> chrono::NaiveDate {
    Utc::now().naive_local().date()
}

pub fn current_time() -> chrono::NaiveTime {
    Utc::now().naive_local().time()
}

pub fn current_datetime() -> chrono::NaiveDateTime {
    Utc::now().naive_local()
}

pub fn current_timestamp() -> chrono::DateTime<Utc> {
    Utc::now()
}

pub fn rand_str(len: usize) -> String {
    Alphanumeric.sample_string(&mut rand::thread_rng(), len)
}
